$.ajaxSetup({
    beforeSend: function(xhr, options) {
        var originalSuccess = options.success
        options.success = function(data, textStatus, jqXhr) {
            originalSuccess.apply(this, arguments)
        }
    }
});

$(document).ajaxSuccess(function( event, request, settings ) {

});

$(document).ajaxError(function( event, request, settings ) {
    if (request.status === 402) {
         window.location.href='/login.html'
    }
});